<?php

namespace Shahu\Common\controller;

use support\Response;

class AdminBaseController
{
    public static array $params = [];

    /**
     * 鉴权失败返回
     * @param $message
     * @return Response
     */
    public static function authorizedError($message): Response
    {
        $returnData = [
            'code' => 401,
            'message' => $message,
            'data' => [
                'login_status' => false,
                'id' => 0,
                'name' => '',
                'phone' => '',
                'role_list' => [],
            ]
        ];
        return json($returnData);
    }

    /**
     * 成功返回
     * @param array $data
     * @param string $message
     * @return Response
     */
    public static function success(array $data = [], string $message = ''): Response
    {
        return json([
            'code' => 200,
            'message' => $message,
            'data' => $data
        ]);
    }

    /**
     * 普通失败返回
     * @param $message
     * @return Response
     */
    public static function fail($message): Response
    {
        return json([
            'code' => 10001,
            'message' => $message,
            'data' => []
        ]);
    }

}
